package com.example.mountainwalker.controller;

import com.example.mountainwalker.entity.ScenicLikeInfo;
import com.example.mountainwalker.service.ScenicLikeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/sclike")
@CrossOrigin
public class ScenicLikeController {
    @Autowired
    private ScenicLikeService scenicLikeService;

    @GetMapping("/find")
    public ResponseEntity<ScenicLikeInfo> getScenicLikeById(@RequestParam Integer id) {
        return ResponseEntity.ok(scenicLikeService.getScenicLikeInfoById(id));
    }

    @GetMapping("/list")
    public ResponseEntity<List<ScenicLikeInfo>> getAllScenicLikes() {
        return ResponseEntity.ok(scenicLikeService.getScenicLikeInfo());
    }

    @DeleteMapping("/delete/{id}")
    public ResponseEntity<Integer> deleteScenicLikeById(@PathVariable Integer id) {
        return ResponseEntity.ok(scenicLikeService.deleteScenicLikeInfoById(id));
    }

    @PostMapping("/insert")
    public ResponseEntity<Integer> insertScenicLikeInfo(@RequestBody ScenicLikeInfo scenicLikeInfo) {
        return ResponseEntity.ok(scenicLikeService.insertScenicLikeInfo(scenicLikeInfo));
    }
}